package org.chenzhi.mvp.activity;

import android.support.annotation.CallSuper;

import org.chenzhi.mvp.base.BasePresenter;
import org.chenzhi.mvp.base.BaseView;

/**
 * @author orange
 * @function
 */

public abstract class BaseMVPActivity<V extends BaseView, T extends BasePresenter<V>> extends BaseActivity {
    protected T mPresenter;

    @CallSuper
    public void init() {
        super.init();
        mvp();
    }

    private void mvp() {
        mPresenter = getPresenter();
        mPresenter.attach((V) this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mPresenter.detach();
    }

    protected abstract T getPresenter();
}
